# ============================================================================
# XENOMORPH CAPTIVE QUEEN - captor-side interactive menu (Direction 2)
#
# A captor empire that HOLDS a captured Xenomorph Queen visits her in the
# holding and chooses how to use her. Modelled on the Family Oriented heir
# menu and the mod's own Captive Pits menu (xeno_captive.*), but from the
# OPPOSITE side: here the player is the captor and the captive IS the Queen.
#
# Kept fully separate from the hive Captive Pits menu (xeno_captive.*) by a
# distinct leader flag: xeno_held_queen (NOT xeno_captured_leader). Reuses the
# shared captive-state layer (xeno_init_captive_state, submission/vitality).
#
# Opened by the edict xeno_visit_captive_queen -> xeno_qcaptive.1
#
# Flow:
#   .900 Start grant: megacorp-civic empires begin holding a captive Queen.
#   .1   Router (hidden): is a Queen held? -> .2 browse, else .5 none.
#   .2   Approach hub (portrait): Show off / Private / Breed / Release / Leave.
#   .10  Show off  (description; sets 2-month cooldown; closes)
#   .20  Private   (description; sets 2-month cooldown; closes)
#   .30  Breed     (description; sets 2-month cooldown; closes)
#   .40  Release   (description; release MECHANIC deferred to effects pass)
#   .5   No Queen held.
#
# EFFECTS/MODIFIERS DEFERRED: per current scope these are choice + description
#   only. The 2-month interaction cooldown is implemented (confirmed pacing);
#   reward modifiers and the real release mechanic come in a later pass.
# ============================================================================

namespace = xeno_qcaptive

# ---- .900 START GRANT ------------------------------------------------------------
# Megacorp-civic captors begin the game already holding a captured Queen.
# Minted from the empire's own Xenomorph species (Xeno Traffickers theme empires
# own one at start). Flagged xeno_held_queen + captive-state initialised.
country_event = {
	id = xeno_qcaptive.900
	hide_window = yes
	is_triggered_only = yes
	fire_only_once = yes

	trigger = {
		is_gestalt = no
		OR = {
			has_civic = civic_xeno_treasured_queens
			# TODO(confirm second megacorp civic): add ONE of
			#   has_civic = civic_xeno_pleasure_products
			#   has_civic = civic_xeno_aliens_of_war
		}
	}

	immediate = {
		if = {
			limit = { any_owned_species = { has_trait = trait_xenomorph } }
			random_owned_species = {
				limit = { has_trait = trait_xenomorph }
				save_event_target_as = xeno_starting_queen_species
			}
			create_leader = {
				class = official
				species = event_target:xeno_starting_queen_species
				name = random
				gender = female
				skill = 3
				traits = { trait = leader_trait_xenomorph_royal_bloodline }
				effect = {
					set_leader_flag = xeno_held_queen
					xeno_init_captive_state = yes
				}
			}
		}
	}
}

# ---- .1 ROUTER -------------------------------------------------------------------
country_event = {
	id = xeno_qcaptive.1
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = { any_owned_leader = { has_leader_flag = xeno_held_queen } }
			random_owned_leader = {
				limit = { has_leader_flag = xeno_held_queen }
				save_event_target_as = xeno_browsed_queen
			}
			country_event = { id = xeno_qcaptive.2 }
		}
		else = {
			country_event = { id = xeno_qcaptive.5 }
		}
	}
}

# ---- .5 NO QUEEN HELD ------------------------------------------------------------
country_event = {
	id = xeno_qcaptive.5
	title = "xeno_qcaptive.title"
	desc = "xeno_qcaptive.5.desc"
	diplomatic = yes
	is_triggered_only = yes

	option = {
		name = "xeno_qcaptive.exit"
	}
}

# ---- .2 APPROACH HUB -------------------------------------------------------------
country_event = {
	id = xeno_qcaptive.2
	title = "xeno_qcaptive.title"
	desc = "xeno_qcaptive.2.desc"
	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:xeno_browsed_queen
		planet_background = root.capital_scope
		graphical_culture = root.owner
		city_level = root.capital_scope
		room = root.ruler
	}

	option = {
		name = "xeno_qcaptive.2.showoff"
		hidden_effect = { country_event = { id = xeno_qcaptive.10 } }
	}
	option = {
		name = "xeno_qcaptive.2.private"
		hidden_effect = { country_event = { id = xeno_qcaptive.20 } }
	}
	option = {
		name = "xeno_qcaptive.2.breed"
		hidden_effect = { country_event = { id = xeno_qcaptive.30 } }
	}
	option = {
		name = "xeno_qcaptive.2.release"
		hidden_effect = { country_event = { id = xeno_qcaptive.40 } }
	}
	option = {
		name = "xeno_qcaptive.exit"
	}
}

# ---- .10 SHOW OFF ----------------------------------------------------------------
country_event = {
	id = xeno_qcaptive.10
	title = "xeno_qcaptive.title"
	desc = "xeno_qcaptive.10.desc"
	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:xeno_browsed_queen
		room = root.ruler
	}

	immediate = {
		set_timed_country_flag = { flag = xeno_queen_visit_cooldown days = 60 }
	}

	option = {
		name = "xeno_qcaptive.continue"
	}
}

# ---- .20 PRIVATE -----------------------------------------------------------------
country_event = {
	id = xeno_qcaptive.20
	title = "xeno_qcaptive.title"
	desc = "xeno_qcaptive.20.desc"
	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:xeno_browsed_queen
		room = root.ruler
	}

	immediate = {
		set_timed_country_flag = { flag = xeno_queen_visit_cooldown days = 60 }
	}

	option = {
		name = "xeno_qcaptive.continue"
	}
}

# ---- .30 BREED / EXTRACT ---------------------------------------------------------
country_event = {
	id = xeno_qcaptive.30
	title = "xeno_qcaptive.title"
	desc = "xeno_qcaptive.30.desc"
	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:xeno_browsed_queen
		room = root.ruler
	}

	immediate = {
		set_timed_country_flag = { flag = xeno_queen_visit_cooldown days = 60 }
	}

	option = {
		name = "xeno_qcaptive.continue"
	}
}

# ---- .40 RELEASE -----------------------------------------------------------------
# Description only for now. The actual release mechanic (return to origin / remove
# from roster) is deferred to the effects pass.
country_event = {
	id = xeno_qcaptive.40
	title = "xeno_qcaptive.title"
	desc = "xeno_qcaptive.40.desc"
	diplomatic = yes
	is_triggered_only = yes

	picture_event_data = {
		portrait = event_target:xeno_browsed_queen
		room = root.ruler
	}

	option = {
		name = "xeno_qcaptive.continue"
	}
}
